#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

#define N 10

int main()
{
    pid_t id=fork();
    if(id==0)
    {
        int cnt=3;
        while(cnt)
        {
            cnt--;
            printf("子进程：%d\n",getpid());
            sleep(1);
        }
        exit(10);
    }

    int status=0;
    pid_t rid=waitpid(-1,&status,0);
    if(rid>0)
    {
        printf("wait success\n");
        if(WIFEXITED(status))
        {
            printf("正常运行结束：%d\n",WEXITSTATUS(status));
        }
        else{
            printf("进程异常了\n");
        }
    }
}
